/*
 *  @ProductName@
 *  Copyright (C) @CopyrightYear@
 *    National Institute of Advanced Industrial Science and Technology (AIST)
 *    Registration Number: @AISTRegistrationNumber@
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package jp.go.aist.six.vuln.model.scap.vulnerability;

import jp.go.aist.six.util.orm.Persistable;
import jp.go.aist.six.vuln.model.scap.core.CheckReference;
import jp.go.aist.six.vuln.model.scap.cvss.CvssImpact;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;




/**
 *
 * @author	Akihito Nakamura, AIST
 * @version $Id: Vulnerability.java 233 2010-06-03 14:29:43Z nakamura5akihito $
 */
public class Vulnerability
    implements Persistable
{

//    private OsvdbExtension  _osvdbExt;
//    private Collection<Platform>  _vulnerableConfiguration;

    private VulnerableSoftware  _vulnerableSoftwareList = new VulnerableSoftware();
    //{0..1}

    private String  _cveID;
    //{choice, cve:cveNamePatternType, 0..1}

//    private String  _cceID; //{choice}

//    private Date  _discoveredDatetime;
//    private Date  _disclosureDatetime;
//    private Date  _exploitPublishDatetime;

    private Date  _publishedDatetime;
    //{xsd:dateTime, 0..1}

    private Date  _lastModifiedDatetime;
    //{xsd:dateTime, 0..1}

    private CvssImpact  _cvss;
    //{0..1}

    private SecurityProtection  _securityProtection;
    //{0..1}

    private Collection<CheckReference>  _assessmentCheck = new ArrayList<CheckReference>();
    //{0..*}

    private Collection<CweReference>  _cwe = new ArrayList<CweReference>();
    //{0..*}

    private Collection<VulnerabilityReference>  _references = new ArrayList<VulnerabilityReference>();
    //{0..*}

//    private Collection<FixAction>  _fixAction;

    /**
     * Denotes a scanner and required configuration
     * that is capable of detecting the referenced vulnerability.
     * May also be an OVAL definition and omit scanner name.
     */
//    private Collection<ToolConfiguration>  _scanner;

    private String  _summary;
    //{0..1}

//    private Collection<Reference>  _technicalDescription;

    /**
     * This element should ultimately be held in a threat model.
     */
//    private Collection<Reference>  _attackScenario;

    private String  _id;
    //{xsd:token, required}



    /**
     * Constructor.
     */
    public Vulnerability()
    {
    }



    /**
     */
    public VulnerableSoftware getVulnerableSoftwareList()
    {
        return _vulnerableSoftwareList;
    }


    /**
     */
    public void setVulnerableSoftwareList(
                    final VulnerableSoftware list
                    )
    {
        _vulnerableSoftwareList = list;
    }



    /**
     * @return the cveID
     */
    public String getCveID()
    {
        return _cveID;
    }


    /**
     * @param cveID the cveID to set
     */
    public void setCveID(
                    final String cveID
                    )
    {
        _cveID = cveID;
    }



    /**
     */
    public Date getPublishedDatetime()
    {
        return _publishedDatetime;
    }


    /**
     */
    public void setPublishedDatetime(
                    final Date datetime
                    )
    {
        _publishedDatetime = datetime;
    }



    /**
     */
    public Date getLastModifiedDatetime()
    {
        return _lastModifiedDatetime;
    }


    /**
     */
    public void setLastModifiedDatetime(
                    final Date datetime
                    )
    {
        _lastModifiedDatetime = datetime;
    }



    /**
     * @param cvss the cvss to set
     */
    public void setCvss(
                    final CvssImpact cvss
                    )
    {
        _cvss = cvss;
    }


    /**
     * @return the cvss
     */
    public CvssImpact getCvss()
    {
        return _cvss;
    }



    /**
     */
    public SecurityProtection getSecurityProtection()
    {
        return _securityProtection;
    }


    /**
     */
    public void setSecurityProtection(
                    final SecurityProtection securityProtection
                    )
    {
        _securityProtection = securityProtection;
    }



    /**
     */
    public Collection<CheckReference> getAssessmentCheck()
    {
        return _assessmentCheck;
    }


    /**
     */
    public void setAssessmentCheck(
                    final Collection<CheckReference> check
                    )
    {
        if (check != _assessmentCheck) {
            _assessmentCheck.clear();
            if (check != null) {
                _assessmentCheck.addAll( check );
            }
        }
    }



    /**
     */
    public Collection<CweReference> getCwe()
    {
        return _cwe;
    }


    /**
     */
    public void setCwe(
                    final Collection<CweReference> cwe
                    )
    {
        if (cwe != _cwe) {
            _cwe.clear();
            if (cwe != null) {
                _cwe.addAll( cwe );
            }
        }
    }



    /**
     */
    public Collection<VulnerabilityReference> getReferences()
    {
        return _references;
    }


    /**
     */
    public void setReferences(
                    final Collection<VulnerabilityReference> references
                    )
    {
        if (references != _references) {
            _references.clear();
            if (references != null) {
                _references.addAll( references );
            }
        }
    }



    /**
     */
    public String getSummary()
    {
        return _summary;
    }


    /**
     */
    public void setSummary(
                    final String summary
                    )
    {
        _summary = summary;
    }



    /**
     */
    public void setID(
                    final String id
                    )
    {
        _id = id;
    }


    /**
     */
    public String getID()
    {
        return _id;
    }



    //**************************************************************
    //  Persistable
    //**************************************************************

    /**
     * The persistent identifier.
     */
//    private  String  _persistentID;


    // id alias persistentID.

    public void setPersistentID(
                    final String id
                    )
    {
        setID( id );
//        _persistentID = id;
    }


    public String getPersistentID()
    {
        return getID();
//        return (_persistentID == null ? getID() : _persistentID);
    }



    //**************************************************************
    //  java.lang.Object
    //**************************************************************

    @Override
    public String toString()
    {
        return "Vulnerability[" + getPersistentID()
                        + ", publishedDatetime=" + getPublishedDatetime()
                        + ", vulnerableSoftware=" + getVulnerableSoftwareList()
                        + "]";
    }

}
// Vulnerability
